#include <bits/stdc++.h>
using namespace std;

const int N = 1101;

class Solution
{
  public:
    int mem[N];
    int dfs(string &nums, int n)
    {
        if (n == 0)
            return 1;
        if (n == 1)
            return nums[0] == '0' ? 0 : 1;
        if (mem[n])
            return mem[n];
        int res = 0;
        if (nums[n - 1] != '0')
            res += dfs(nums, n - 1);
        int two = (nums[n - 2] - '0') * 10 + nums[n - 1] - '0';
        if (two >= 10 && two <= 26)
        {
            res += dfs(nums, n - 2);
        }
        return mem[n] = res;
    }
    int solve(string nums)
    {
        int n = nums.size();
        // return dfs(nums, n);
        vector<int> dp(n + 2, 0);
        dp[0] = 1;
        dp[1] = nums[0] == '0' ? 0 : 1;
        for (int i = 2; i <= n; i++)
        {
            if (nums[i - 1] != '0')
                dp[i] += dp[i - 1];
            int two = (nums[i - 2] - '0') * 10 + nums[i - 1] - '0';
            if (two >= 10 && two <= 26)
                dp[i] += dp[i - 2];
        }
        return dp[n];
    }
};